# 导包
import torch

y_true = torch.tensor([[0,1,0],[0,0.2,0.8]],dtype=torch.float)


y_pred = torch.tensor([[0.1,0.7,0.2],[0.1,0.3,0.6]],requires_grad=True,dtype=torch.float)

entropy_loss = torch.nn.CrossEntropyLoss()

loss = entropy_loss(y_pred, y_true)
print(loss)

